
#include <serpent.h>
#include "serpentd.h"
#include "serpentd_props.h"

void usage(void)
{
	printf("USAGE: serpentd [-h] [-v]\n"
			"\t\t-h show this\n"
			"\t\t-v show version\n"
			"\n"
			);
}

void version(void) {
	printf("serpent %s by %s under %s, built %s.\n%s\n", VERSION, AUTHOR, LICENSE, BUILD, URL);
}


int main(int argc, char* argv[]) {

	int opt,ret;
	queue sysq;

	while( -1 != ( opt = getopt(argc, argv, "vh") ) )
	{
		switch(opt)
		{
			case 'v':
				version();
				exit(1);
				break;
			case 'h':
				usage();
				version();
				exit(1);
				break;
		}
	}

	if( !s_init() )
	{
		printf("could not call s_init properly.\n");
		exit(1);
	}

	if( !(sysq = (queue)create_queue("sysq")) )
	{
		printf("could not create queue sysq.\n");
		exit(1);
	}

	if( !prop_add(sysq,"test","123") )
	{
		printf("could not create property test.\n");
		exit(1);
	}
	if( !prop_add(sysq,"test2","456") )
	{
		printf("could not create property test2\n");
		exit(1);
	}

	if( prop_exists(sysq,"name") )
	{
		if( !prop_set(sysq,"name","sysq2") )
		{
			printf("could not set new name.\n");
		}
	}

	printf("name of the queue = %s\n", prop_get(sysq,"name") );

	if( !prop_del(sysq,"test") )
	{
		printf("could not delete property test.\n");
		exit(1);
	}
	if( !prop_del(sysq,"test2") )
	{
		printf("could not delete property test2.\n");
	}

	if( !s_exit() )
	{
		printf("could not call s_exit properly.\n");
		exit(1);
	}

	return(0);
}
